package com.bytedance.improvingroad.binder.server

import android.app.Service
import android.content.Intent
import android.os.IBinder
import android.os.RemoteException
import android.util.Log
import com.bytedance.improvingroad.binder.Book

/**
 * Created by chenxiong
 * date 12/14/21
 */
class RemoteService: Service() {

    private val books = mutableListOf<Book>()
    override fun onBind(intent: Intent?): IBinder {
        Log.e("cx","onBind------")
        return bookManager
    }

    private val bookManager: Stub = object : Stub() {

        @Throws(RemoteException::class)
        override fun getBooks(): List<Book?> {
            return books
        }

        @Throws(RemoteException::class)
        override fun addBook(book: Book) {
            books.add(book)
        }
    }
}